package top.upstudy.crm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import top.upstudy.base.ResultInfo;
import top.upstudy.crm.pojo.ProvCityAreaStreet;
import top.upstudy.crm.service.ProvCityAreaStreetService;

import java.util.List;

@Controller
@RequestMapping("/prov")
public class ProvCityAreaStreetController {
    @Autowired
    ProvCityAreaStreetService provCityAreaStreetService;

    @GetMapping("/findProvSheng")
    @ResponseBody
    public ResultInfo findProvSheng(int code){
        List<ProvCityAreaStreet> city = provCityAreaStreetService.findSheng(code);
        ResultInfo resultInfo=new ResultInfo();
        resultInfo.setResult(city);
        return resultInfo;
    }

    @GetMapping("/findProvShi")
    @ResponseBody
    public ResultInfo findProvShi(int code){
        List<ProvCityAreaStreet> city = provCityAreaStreetService.findShi(code);
        ResultInfo resultInfo=new ResultInfo();
        resultInfo.setResult(city);
        return resultInfo;
    }

    @GetMapping("/findProvQu")
    public ResultInfo findProvQu(int code){
        List<ProvCityAreaStreet> city = provCityAreaStreetService.findQu(code);
        ResultInfo resultInfo=new ResultInfo();
        resultInfo.setResult(city);
        return resultInfo;
    }

    @GetMapping("/findProvJieDao")
    @ResponseBody
    public ResultInfo findProvJieDao(int code){
        List<ProvCityAreaStreet> city = provCityAreaStreetService.findJieDao(code);
        ResultInfo resultInfo=new ResultInfo();
        resultInfo.setResult(city);
        return resultInfo;
    }

    @RequestMapping("/toProv")
    @ResponseBody
    public ModelAndView findProvJieDao(ModelAndView modelAndView){
        modelAndView.setViewName("MyProv");
        System.out.println(999999999);
        ResultInfo provSheng = findProvSheng(1);
        System.out.println(provSheng);
        modelAndView.addObject("prov",provSheng);
        return modelAndView;
    }
}
